package com.fjw.service.impl;

import com.fjw.dao.UserDao;
import com.fjw.dao.impl.UserDaoImpl;
import com.fjw.entity.User;
import com.fjw.service.UserService;

import java.sql.SQLException;
import java.util.List;

public class UserServiceImpl  implements UserService {
    private UserDao userDao = new UserDaoImpl();

    @Override
    public User selectByUnameAndUpwd(String uname, String upwd) {
        List<User> userList = null;
        try {
            userList = userDao.selectByUname(uname);
        } catch (SQLException e) {
            throw new RuntimeException(e);
        }
        if(userList !=null && userList.size() >0){
            for(User user :userList){
                if(user !=null){
                    //比较密码是否相同
                    if(upwd.equals(user.getUpwd())){
                        return user;
                    }
                }
            }
        }
        return null;
    }
}
